<!DOCTYPE html>
<html >
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="潍夫子" />



<meta name="description" content="在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。
找到项目中的**.xcodeproj文件，点击右键，show package contents(打开包内容)。打开后找到pr">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS知识总结<一>">
<meta property="og:url" content="http://weifuzi.oschina.io/2017/02/08/iOS-summary/index.html">
<meta property="og:site_name" content="潍夫子的个人博客">
<meta property="og:description" content="在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。
找到项目中的**.xcodeproj文件，点击右键，show package contents(打开包内容)。打开后找到pr">
<meta property="og:updated_time" content="2018-05-30T03:16:24.619Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS知识总结<一>">
<meta name="twitter:description" content="在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。
找到项目中的**.xcodeproj文件，点击右键，show package contents(打开包内容)。打开后找到pr">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="潍夫子的个人博客" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>iOS知识总结&lt;一&gt; | 潍夫子的个人博客</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script> yiliaConfig.jquery_ui = [false]; </script>



    <script> yiliaConfig.rootUrl = "\/";</script>






</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">潍夫子</a></h1>
        </hgroup>

        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/tags/">标签云</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:yuyekuangmo@qq.com" title="Email"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                
                

                
                
                <section class="switch-part switch-part3">
                
                    <div id="js-aboutme">没事打酱油</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">潍夫子</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">潍夫子</a></h1>
            </hgroup>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/tags/">标签云</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:yuyekuangmo@qq.com" title="Email"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="Tags" friends="Friends" about="About Me"/>
</nav>
      <div class="body-wrap"><article id="post-iOS-summary" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/02/08/iOS-summary/" class="article-date">
      <time datetime="2017-02-08T06:07:11.000Z" itemprop="datePublished">2017-02-08</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      iOS知识总结&lt;一&gt;
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/术业专攻/">术业专攻</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/总结/">总结</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h3 id="在Archive项目时，出现了“Your-build-settings-specify-a-provisioning-profile-with-the-UUID-“”-however-no-such-provisioning-profile-was-found”的出错。"><a href="#在Archive项目时，出现了“Your-build-settings-specify-a-provisioning-profile-with-the-UUID-“”-however-no-such-provisioning-profile-was-found”的出错。" class="headerlink" title="在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。"></a>在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。</h3><ol>
<li>找到项目中的**.xcodeproj文件，点击右键，show package contents(打开包内容)。打开后找到project.pbxproj文件，用文本编辑器打开。其实就是右键，点击open就好了。</li>
<li>打开这个文件后，按command+F，在这个文件中查找“PROVISIONING_PROFILE”,找到和这个类似的都删除然后保存文件，重新打开项目</li>
</ol>
<h3 id="只在debug模式打印NSLog"><a href="#只在debug模式打印NSLog" class="headerlink" title="只在debug模式打印NSLog"></a>只在debug模式打印NSLog</h3><p>打开project–&gt;Build setting选项，在下面找LLVM GCC4.2-preprocessing下面的－preprocessor macros  下一级 Debug中设置DEBUG＝1或$(inherited)<br>在pch文件中</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">#ifdef DEBUG</div><div class="line">     #else</div><div class="line">     #define NSLog(...)&#123;&#125;;</div><div class="line">     #endif</div></pre></td></tr></table></figure>
<h3 id="设置应用的本地化语言"><a href="#设置应用的本地化语言" class="headerlink" title="设置应用的本地化语言"></a>设置应用的本地化语言</h3><p>踩过个坑，上传到AppStore的应用，应用描述里的语言项始终不能如意，其实是没有在应用的info.plist文件配置</p>
<blockquote>
<p>选择工程的plist文件设置Localization native development region为所需要的语言</p>
</blockquote>
<h3 id="解决NSTimer因控件滚动而停止"><a href="#解决NSTimer因控件滚动而停止" class="headerlink" title="解决NSTimer因控件滚动而停止"></a>解决NSTimer因控件滚动而停止</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];</div></pre></td></tr></table></figure>
<h3 id="UILabel设置行间距及主动换行和居中"><a href="#UILabel设置行间距及主动换行和居中" class="headerlink" title="UILabel设置行间距及主动换行和居中"></a>UILabel设置行间距及主动换行和居中</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@&quot;发布第一张图为商品封面\n最多可以上传8张图片&quot;];</div><div class="line">NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];</div><div class="line">[paragraphStyle setLineSpacing:8.5 * BIAOZHUN];</div><div class="line">paragraphStyle.alignment = NSTextAlignmentCenter;</div><div class="line">[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];</div><div class="line">label.attributedText = attributedStr;</div><div class="line">label.numberOfLines = 2;</div></pre></td></tr></table></figure>
<h3 id="Label或UIButton下划线"><a href="#Label或UIButton下划线" class="headerlink" title="Label或UIButton下划线"></a>Label或UIButton下划线</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@&quot;下次再说&quot;];</div><div class="line">[str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, str.length)];</div></pre></td></tr></table></figure>
<h3 id="多次移除观察者导致程序崩溃解决方法"><a href="#多次移除观察者导致程序崩溃解决方法" class="headerlink" title="多次移除观察者导致程序崩溃解决方法"></a>多次移除观察者导致程序崩溃解决方法</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">1）@try &#123;[_progress removeObserver:self forKeyPath:@&quot;completedUnitCount&quot;];&#125;</div><div class="line">         @catch (NSException *exception) &#123; NSLog(@&quot;多次删除了&quot;);&#125;</div><div class="line">2）给是否移除做上标记</div></pre></td></tr></table></figure>
<h3 id="UICollectionView不执行viewForSupplementaryElementOfKind方法"><a href="#UICollectionView不执行viewForSupplementaryElementOfKind方法" class="headerlink" title="UICollectionView不执行viewForSupplementaryElementOfKind方法"></a>UICollectionView不执行viewForSupplementaryElementOfKind方法</h3><p>要先实现UICollectionViewDelegateFlowLayout协议里的<code>func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int)</code></p>
<h3 id="跳转到AppStore的APP网络路径"><a href="#跳转到AppStore的APP网络路径" class="headerlink" title="跳转到AppStore的APP网络路径"></a>跳转到AppStore的APP网络路径</h3><blockquote>
<p><a href="http://itunes.apple.com/app/id(your" target="_blank" rel="external">http://itunes.apple.com/app/id(your</a> apple id)</p>
</blockquote>
<h3 id="NSAssert-函数使用"><a href="#NSAssert-函数使用" class="headerlink" title="NSAssert()函数使用"></a>NSAssert()函数使用</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">NSAssert(x!=0,@&quot;x must be zero&quot;);</div></pre></td></tr></table></figure>
<p>在表达式“x!=0”不成立时，程序就会抛出异常，并显示自定义的消息”x must be zero”，并同时显示出错的文件、代码和调用函数等信息，是一个程序追踪的很好手段。 假设x!=0，不满足要求就提示reason-x must not be zero;</p>
<h3 id="程序后台运行一段时间"><a href="#程序后台运行一段时间" class="headerlink" title="程序后台运行一段时间"></a>程序后台运行一段时间</h3><p>当应用按Home键退出后，应用仅有最多5秒钟的时间做一些保存和清理资源的工作。但是应用可以调用UIApplication的 beginBackgroundTaskWithExpirationHandler方法，让应用最多有10分钟的时间在后台长久运行。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">//AppDelegate.h文件</div><div class="line">    @property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundUpdateTask;</div><div class="line"></div><div class="line">//AppDelegate.m文件</div><div class="line">- (void)applicationDidEnterBackground:(UIApplication *)application &#123;</div><div class="line">  self.backgroundUpdateTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^&#123;</div><div class="line">     [self endBackgroundUpdateTask];</div><div class="line"> &#125;];</div><div class="line"> </div><div class="line">	//在这里加上需要执行的操作</div><div class="line"></div><div class="line">    [self endBackgroundUpdateTask];</div><div class="line">&#125;</div><div class="line"></div><div class="line">- (void)endBackgroundUpdateTask&#123;</div><div class="line">   [[UIApplication sharedApplication] endBackgroundTask:self.backgroundUpdateTask];</div><div class="line">   self.backgroundUpdateTask = UIBackgroundTaskInvalid;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="配置pch文件"><a href="#配置pch文件" class="headerlink" title="配置pch文件"></a>配置pch文件</h3><blockquote>
<ol>
<li>新建文件-&gt;other-&gt;pchfile</li>
<li>build Settings-&gt;搜索prefix-&gt;Prefix Header中添加路径$(SRCROOT)/文件名.pch</li>
</ol>
</blockquote>
<h3 id="限制TextView或TextField的输入字数-textView只走第二步，有代理方法"><a href="#限制TextView或TextField的输入字数-textView只走第二步，有代理方法" class="headerlink" title="限制TextView或TextField的输入字数(textView只走第二步，有代理方法)"></a>限制TextView或TextField的输入字数(textView只走第二步，有代理方法)</h3><ul>
<li>添加监听</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChanged:) name:UITextFieldTextDidChangeNotification object:_goodsNameTF];</div></pre></td></tr></table></figure>
<ul>
<li>实现监听方法</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">- (void)textFieldChanged:(NSNotification *)obj&#123;</div><div class="line">    UITextField *textField = (UITextField *)obj.object;</div><div class="line">    NSInteger kMaxLength = 20;</div><div class="line"></div><div class="line">    NSString *toBeString = textField.text;</div><div class="line">    NSString *lang = [[UITextInputMode currentInputMode] primaryLanguage]; // 键盘输入模式</div><div class="line">    if ([lang isEqualToString:@&quot;zh-Hans&quot;]) &#123; // 简体中文输入，包括简体拼音，健体五笔，简体手写</div><div class="line">        //获取高亮部分</div><div class="line">        UITextRange *selectedRange = [textField markedTextRange];</div><div class="line">        // 没有高亮选择的字，则对已输入的文字进行字数统计和限制</div><div class="line">        UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];</div><div class="line">        if (!position) &#123;</div><div class="line">            if (toBeString.length &gt; kMaxLength) &#123;</div><div class="line">                textField.text = [toBeString substringToIndex:kMaxLength];</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        // 有高亮选择的字符串，则暂不对文字进行统计和限制</div><div class="line">        else&#123;</div><div class="line"></div><div class="line">        &#125;</div><div class="line">    &#125;else&#123;// 中文输入法以外的直接对其统计限制即可，不考虑其他语种情况</div><div class="line">        if (toBeString.length &gt; kMaxLength) &#123;</div><div class="line">            textField.text = [toBeString substringToIndex:kMaxLength];</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>在dealloc里注销监听</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:_goodsNameTF];</div></pre></td></tr></table></figure>
<h3 id="CABasicAnimation如何让多个动画顺序执行"><a href="#CABasicAnimation如何让多个动画顺序执行" class="headerlink" title="CABasicAnimation如何让多个动画顺序执行"></a>CABasicAnimation如何让多个动画顺序执行</h3><p>只需要在后面的动画中设置：<code>animation(对象).beginTime = CACurrentMediaTime() + 0.2;</code>(前一个动画所需时间)</p>
<h3 id="扫码全屏显示设置扫描区域"><a href="#扫码全屏显示设置扫描区域" class="headerlink" title="扫码全屏显示设置扫描区域"></a>扫码全屏显示设置扫描区域</h3><p>设置AVCaptureMetadataOutput的rectOfInterest的属性：CGRectMake（y的起点/屏幕的高，x的起点/屏幕的宽，扫描的区域的高/屏幕的高，扫描的区域的宽/屏幕的宽）</p>
<h3 id="设置collectionView的cell点击高亮效果"><a href="#设置collectionView的cell点击高亮效果" class="headerlink" title="设置collectionView的cell点击高亮效果"></a>设置collectionView的cell点击高亮效果</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath           *)indexPath&#123;</div><div class="line">    return YES;</div><div class="line">&#125;</div><div class="line">- (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath&#123;</div><div class="line">    UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];</div><div class="line">    [cell setBackgroundColor:[UIColor colorWithHexString:@&quot;#dcdcdc&quot;]];</div><div class="line">&#125;</div><div class="line">- (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath&#123;</div><div class="line">    UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];</div><div class="line">    [UIView animateWithDuration:0.4 animations:^&#123;</div><div class="line">        [cell setBackgroundColor:[UIColor whiteColor]];</div><div class="line">    &#125;];</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="设置StatusBar"><a href="#设置StatusBar" class="headerlink" title="设置StatusBar"></a>设置StatusBar</h3><ul>
<li>方法一：全局控制StatusBar<ol>
<li>在项目的Info.plist文件里设置UIViewControllerBasedStatusBarAppearance为NO。（默认为yes）</li>
<li>使用[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];方法设置颜色。</li>
</ol>
</li>
<li><p>方法二：基于控制器的方式控制StatusBar</p>
<ol>
<li>在项目的Info.plist文件里设置UIViewControllerBasedStatusBarAppearance为YES。</li>
<li>在各个UIViewController里分别控制状态栏的颜色和状态。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">- (UIStatusBarStyle)preferredStatusBarStyle&#123;&#125;</div><div class="line">- (BOOL)prefersStatusBarHidden&#123;&#125;</div><div class="line">*[self setNeedsStatusBarAppearanceUpdate];可以调起(UIStatusBarStyle)preferredStatusBarStyle动态改变状态栏*</div></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="UILabel显示html文本"><a href="#UILabel显示html文本" class="headerlink" title="UILabel显示html文本"></a>UILabel显示html文本</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">NSString * htmlString = @&quot;&lt;html&gt;&lt;body&gt; Some html string \n &lt;font size=\&quot;13\&quot; color=\&quot;red\&quot;&gt;This is some text!&lt;/font&gt; &lt;/body&gt;&lt;/html&gt;&quot;;</div><div class="line">NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@&#123; NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType &#125; documentAttributes:nil error:nil];</div><div class="line">UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];</div><div class="line">myLabel.attributedText = attrStr;</div><div class="line">[self.view addSubview:myLabel];</div></pre></td></tr></table></figure>
<h3 id="获取相机权限"><a href="#获取相机权限" class="headerlink" title="获取相机权限"></a>获取相机权限</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">#import &lt;AVFoundation/AVFoundation.h&gt;</div><div class="line">AVAuthorizationStatus authorStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];</div><div class="line">if (authorStatus != 3) &#123;</div><div class="line">    [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) &#123;</div><div class="line">    </div><div class="line">    &#125;];</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="xcode的证书存储路径"><a href="#xcode的证书存储路径" class="headerlink" title="xcode的证书存储路径"></a>xcode的证书存储路径</h3><p><code>~/Library/MobileDevice/Provisioning Profiles</code></p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>Title:</span><a href="/2017/02/08/iOS-summary/">iOS知识总结&lt;一&gt;</a></p>
        <p><span>Author:</span><a href="/" title="Back to Homepage">潍夫子</a></p>
        <p><span>Created:</span>2017-02-08, 14:07:11</p>
        <p><span>Updated:</span>2018-05-30, 11:16:24</p>
        <p>
            <span>Full URL:</span><a class="post-url" href="/2017/02/08/iOS-summary/" title="iOS知识总结&lt;一&gt;">http://weifuzi.oschina.io/2017/02/08/iOS-summary/</a>
            <span class="copy-path" data-clipboard-text="From http://weifuzi.oschina.io/2017/02/08/iOS-summary/　　By 潍夫子" title="Copy Article&#39;s Link &amp; Author"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>License:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"CC BY-NC-SA 4.0"</a> Keep Link &amp; Author if Distribute.
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/2017/03/28/Efficiency-XcodeTemplate/">
                    高效工作--自定义Xcode类模板
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/2017/02/06/interview/">
                    iOS问题总结&lt;二&gt;
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">Contents</strong>
        
            <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#在Archive项目时，出现了“Your-build-settings-specify-a-provisioning-profile-with-the-UUID-“”-however-no-such-provisioning-profile-was-found”的出错。"><span class="toc-number">1.</span> <span class="toc-text">在Archive项目时，出现了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出错。</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#只在debug模式打印NSLog"><span class="toc-number">2.</span> <span class="toc-text">只在debug模式打印NSLog</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#设置应用的本地化语言"><span class="toc-number">3.</span> <span class="toc-text">设置应用的本地化语言</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#解决NSTimer因控件滚动而停止"><span class="toc-number">4.</span> <span class="toc-text">解决NSTimer因控件滚动而停止</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#UILabel设置行间距及主动换行和居中"><span class="toc-number">5.</span> <span class="toc-text">UILabel设置行间距及主动换行和居中</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Label或UIButton下划线"><span class="toc-number">6.</span> <span class="toc-text">Label或UIButton下划线</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#多次移除观察者导致程序崩溃解决方法"><span class="toc-number">7.</span> <span class="toc-text">多次移除观察者导致程序崩溃解决方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#UICollectionView不执行viewForSupplementaryElementOfKind方法"><span class="toc-number">8.</span> <span class="toc-text">UICollectionView不执行viewForSupplementaryElementOfKind方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#跳转到AppStore的APP网络路径"><span class="toc-number">9.</span> <span class="toc-text">跳转到AppStore的APP网络路径</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#NSAssert-函数使用"><span class="toc-number">10.</span> <span class="toc-text">NSAssert()函数使用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#程序后台运行一段时间"><span class="toc-number">11.</span> <span class="toc-text">程序后台运行一段时间</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#配置pch文件"><span class="toc-number">12.</span> <span class="toc-text">配置pch文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#限制TextView或TextField的输入字数-textView只走第二步，有代理方法"><span class="toc-number">13.</span> <span class="toc-text">限制TextView或TextField的输入字数(textView只走第二步，有代理方法)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#CABasicAnimation如何让多个动画顺序执行"><span class="toc-number">14.</span> <span class="toc-text">CABasicAnimation如何让多个动画顺序执行</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#扫码全屏显示设置扫描区域"><span class="toc-number">15.</span> <span class="toc-text">扫码全屏显示设置扫描区域</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#设置collectionView的cell点击高亮效果"><span class="toc-number">16.</span> <span class="toc-text">设置collectionView的cell点击高亮效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#设置StatusBar"><span class="toc-number">17.</span> <span class="toc-text">设置StatusBar</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#UILabel显示html文本"><span class="toc-number">18.</span> <span class="toc-text">UILabel显示html文本</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#获取相机权限"><span class="toc-number">19.</span> <span class="toc-text">获取相机权限</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#xcode的证书存储路径"><span class="toc-number">20.</span> <span class="toc-text">xcode的证书存储路径</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="Hide"  title="Show or Hide Table of Contents">

    <script>
        yiliaConfig.toc = ["Hide", "Show", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"iOS知识总结<一>　| 潍夫子的个人博客　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    




    <div class="scroll" id="post-nav-button">
        
            <a href="/2017/03/28/Efficiency-XcodeTemplate/" title="Pre: 高效工作--自定义Xcode类模板">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="Mini Archives"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/2017/02/06/interview/" title="Next: iOS问题总结&lt;二&gt;">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2019/04/02/buyHouse/">置业储备</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/03/28/CSS初探/">CSS初探</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/03/28/html标签初探/">html标签初探</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/05/30/iOS11Safearea/">iOS11 SafeArea适配相关</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/28/Efficiency-XcodeTemplate/">高效工作--自定义Xcode类模板</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/02/08/iOS-summary/">iOS知识总结<一></a></li><li class="post-list-item"><a class="post-list-link" href="/2017/02/06/interview/">iOS问题总结<二></a></li><li class="post-list-item"><a class="post-list-link" href="/2017/02/05/creatMyBlog/">免费个人博客搭建（Hexo+osChina）</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2017-2019 潍夫子
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="A fast, simple &amp; powerful blog framework">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="Another simple and elegant theme for Hexo  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="Site Visitors"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="Page Hits"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





<div class="scroll" id="scroll">
    <a href="#" title="Back to Top"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="Comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="Go to Bottom"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>